﻿<UserControl x:Class="Bio.Views.Alignment.Views.TaxonmyJumpView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
        xmlns:julmar="http://www.julmar.com/wpfhelpers" Background="#FF595959">
    <Grid>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <TextBlock TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Foreground="White"
                   Text="Select the specific Taxonomy to jump to in the list below" Margin="5" HorizontalAlignment="Left" />
        
        <Border Grid.Row="1" BorderBrush="White" BorderThickness="1" Background="#FF333333" Margin="2">
            <TreeView x:Name="tv" ItemsSource="{Binding Root}" Margin="5" BorderBrush="Black" BorderThickness="1" SelectedItemChanged="tv_SelectedItemChanged">
                <TreeView.ItemTemplate>
                    <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock x:Name="name" Text="{Binding Name}" Margin="5,0" FontWeight="Bold" Foreground="Yellow" />
                            <StackPanel x:Name="count" Orientation="Horizontal">
                                <TextBlock Text="(" />
                                <TextBlock Text="{Binding Count}" />
                                <TextBlock Text=")" />
                            </StackPanel>
                            <StackPanel x:Name="totalCount" Orientation="Horizontal" Margin="5,0" TextElement.Foreground="LightGreen">
                                <TextBlock Text="(" />
                                <TextBlock Text="{Binding TotalCount}" />
                                <TextBlock Text=")" />
                            </StackPanel>
                        </StackPanel>
                        <DataTemplate.Triggers>
                            <DataTrigger Binding="{Binding Count}" Value="0">
                                <Setter Property="Visibility" Value="Collapsed" TargetName="count" />
                                <Setter Property="FontWeight" Value="Normal" TargetName="name" />
                                <Setter Property="Foreground" Value="White" TargetName="name" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding TotalCount}" Value="0">
                                <Setter Property="Visibility" Value="Collapsed" TargetName="totalCount" />
                            </DataTrigger>
                        </DataTemplate.Triggers>
                    </HierarchicalDataTemplate>
                </TreeView.ItemTemplate>
                <TreeView.ItemContainerStyle>
                    <Style TargetType="TreeViewItem" BasedOn="{StaticResource {x:Type TreeViewItem}}">
                        <Setter Property="IsExpanded" Value="{Binding IsExpanded}" />
                    </Style>
                </TreeView.ItemContainerStyle>
            </TreeView>
        </Border>
        
        <Grid Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            
            <CheckBox Content="Select Rows in Alignment View" VerticalAlignment="Center" Margin="5" IsChecked="{Binding SelectRowsInAlignmentView}" />
            
            <StackPanel Orientation="Horizontal" Grid.Row="1">
                <Label VerticalAlignment="Center" Margin="5">Level:</Label>                
                <TextBox Margin="5" MinWidth="100" Text="{Binding CollapseLevel, UpdateSourceTrigger=PropertyChanged}">
                    <Interactivity:Interaction.Behaviors>
                        <julmar:NumericTextBoxBehavior AllowMouseDrag="True" />
                    </Interactivity:Interaction.Behaviors>
                </TextBox>
            </StackPanel>
            <Button Grid.Column="1" Grid.RowSpan="2" Content="Close" IsCancel="True" Margin="5" Command="{Binding CloseView}"
                    Visibility="{Binding IsDocked, Converter={julmar:BooleanToVisibilityConverter TrueTreatment=Collapsed, FalseTreatment=Visible}}"
                    Padding="10,5" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
        </Grid>
         
        <Border Background="#FF535353" Grid.RowSpan="3">
            <Border.Style>
                <Style TargetType="Border">
                    <Setter Property="Visibility" Value="Collapsed" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding}" Value="{x:Null}">
                            <Setter Property="Visibility" Value="Visible" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
            <Label HorizontalAlignment="Center" VerticalAlignment="Center" Content="No Taxonomy Data" />
        </Border>
        
    </Grid>
</UserControl>
